package com.iwayin.core.common;

import java.util.HashMap;
import java.util.Map;

/**
 * BO调用返回结果类
 * 
 * @author xiaobo.feng<xiaobo.feng@foxmail.com>
 * 
 *         Aug 27, 2011
 */
public class BOResult {

	public final static boolean SUCCESS = true;
	public final static boolean FAILURE = false;
	public final static int EXECUTE_SUCCESS = 1;
	/**
	 * 操作执行结果
	 */
	private boolean success;
	/**
	 * 错误描述码
	 */
	private String errorCode;

	/**
	 * 返回信息
	 */
	private Object body;

	@SuppressWarnings("rawtypes")
	private Map resultMap = new HashMap();

	public BOResult(boolean isSuccess, String errorCode) {
		this.success = isSuccess;
		this.errorCode = errorCode;
	}

	public BOResult(boolean isSuccess) {
		this.success = isSuccess;
	}

	public BOResult(boolean isSuccess, String errorCode, Object body) {
		this.success = isSuccess;
		this.errorCode = errorCode;
		this.body = body;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public Object getBody() {
		return body;
	}

	public void setBody(Object body) {
		this.body = body;
	}

	public Object getResult(Object key) {
		return resultMap.get(key);
	}

	@SuppressWarnings("unchecked")
	public void putResult(Object k, Object v) {
		resultMap.put(k, v);
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public void putAll(Map map) {
		resultMap.putAll(map);
	}

	@SuppressWarnings("rawtypes")
	public Map getAll() {
		return resultMap;
	}

}
